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AAA,KAAAA,EAAAA,EAAO6B,OAAP7B,EAAgB,IAAK,OAAS,MAAQ,KACnD,EAEA,MACE,UAAC8B,EAAAA,CAAcA,CAAAA,CAACC,OAAQvB,WACtB,UAACwB,EAAAA,CAAiBA,CAACC,QAAQ,EAACC,MAAOZ,WACjC,UAACa,EAAAA,CAAMA,CAAAA,CACLnB,UAAWA,EACXoB,UAAWnB,EACXI,MAAOA,EACPD,6BAA8BA,EAC9BD,4BAA6BA,EAC7BhB,aAAcA,EACdkC,QAAQ,GACRnB,UAAWA,EACXoB,OAAO,iCAEP,UAACC,EAAAA,cAAcA,CAAAA,CACZ,GAAG5B,CAAmB,CACvBX,MAAOA,EACPwC,SAAU7C,EACV8C,SAAU5C,SAMtB","sources":["webpack://_N_E/?2240","webpack://_N_E/./pages/einterface/v5/[index].tsx"],"sourcesContent":["\n    (window.__NEXT_P = window.__NEXT_P || []).push([\n      \"/einterface/v5/[index]\",\n      function () {\n        return require(\"private-next-pages/einterface/v5/[index].tsx\");\n      }\n    ]);\n    if(module.hot) {\n      module.hot.dispose(function () {\n        window.__NEXT_P.push([\"/einterface/v5/[index]\"])\n      });\n    }\n  ","/* eslint-disable @typescript-eslint/no-explicit-any */\nimport React from 'react';\nimport { ResponsiveGrid } from '@adobe/aem-react-editable-components';\nimport { ApolloProvider } from '@apollo/client';\nimport { PageParamsContext } from '@marriott/mi-ppv5-components';\nimport { getDeployedEnvType, useNextMiApolloClient } from '@marriott/mi-apollo-client-utils';\nimport { Layout, respGridUtil, getProcessEnvs, prePageCall } from '@marriott/mi-headless-utils';\nimport { constants } from '@marriott/mi-ppv5-components/constants';\nimport { GetServerSideProps } from 'next';\nimport { inspect } from 'util';\nimport { userStates } from './../../../_constants/states';\nimport { mockModel } from '../../../_localDevMocks/mockModel';\nimport operationSignatures from '../../../_constants/operationSignatures.json';\n\nconst {\n  NEXT_PUBLIC_AEM_PATH,\n  INVALID_REDIRECT_URL,\n  NEXT_PUBLIC_PRE_PROCESSING_PPV5_URL,\n  IS_LOCAL_DEV,\n  NEXT_PUBLIC_APP_NAME,\n} = getProcessEnvs();\nconst { ITEM_PATH_ROOT } = constants;\n\n// final data would have to come from 2 calls:\n// 1. Page level call from AEM - that will populate the labels on components\n// 2. Functional data for components like list of amenities and other related information\n// import jsonContent from '../../mock/label-info.json';\n\nexport default function PropertyPortalPage({\n  model,\n  deployedEnvType,\n  isAuthorMode,\n  headersData,\n  requestId,\n  currentLocale,\n  lang,\n  preProcessorResponse,\n}) {\n  const MiApolloClient = useNextMiApolloClient(operationSignatures, deployedEnvType);\n\n  const responsiveGridModel = respGridUtil(model?.cqItems?.root?.[':items']?.responsivegrid);\n  const { metaNames, metaProperties, canonical, staticComponentClientLibsJS, staticComponentClientLibsCSS, title } =\n    model;\n  const context = {\n    sessionID: headersData.sessionid,\n    preProcessorResponse: preProcessorResponse ?? {},\n    requestId,\n    currentLocale,\n    lang: preProcessorResponse?.locale ?? lang,\n    localePath: preProcessorResponse?.subDirectory,\n    direction: model?.rtlEnable === 'true' ? 'rtl' : 'ltr',\n  };\n\n  return (\n    <ApolloProvider client={MiApolloClient}>\n      <PageParamsContext.Provider value={context}>\n        <Layout\n          metaNames={metaNames}\n          metaProps={metaProperties}\n          title={title}\n          staticComponentClientLibsCSS={staticComponentClientLibsCSS}\n          staticComponentClientLibsJS={staticComponentClientLibsJS}\n          isAuthorMode={isAuthorMode}\n          gridCss=\"\"\n          canonical={canonical}\n          mainID=\"marriott-main-content\"\n        >\n          <ResponsiveGrid\n            {...responsiveGridModel}\n            model={model}\n            pagePath={NEXT_PUBLIC_AEM_PATH}\n            itemPath={ITEM_PATH_ROOT}\n          />\n        </Layout>\n      </PageParamsContext.Provider>\n    </ApolloProvider>\n  );\n}\n\n//Any product specific page data apart from common data like session, datalayer\n//can be returned from this function and the same is passed as props to the page Component\nconst ppv5SpecificData = async context => {\n  const { log } = global.loggerInstance('PPv5Preprocessor:');\n  //any page specific code can be written here.\n  const deployedEnvType = getDeployedEnvType();\n  const error: Record<string, any> = {};\n  let preprocessorURL = NEXT_PUBLIC_PRE_PROCESSING_PPV5_URL;\n  let response: Record<string, any> = {};\n  const query = new URLSearchParams(context.query).toString();\n  const state = context.query.state;\n  const user = context.query.user;\n  let EXPERIENCE_SEGMENT = [];\n\n  const sampleResponse = {\n    userSegment: 'NOT Logged In',\n    validMarsha: true,\n    status: 'SUCCESS',\n    message: '',\n    statusCode: '200',\n    brandCode: 'mc',\n    experienceSegment: 'In_Stay-Unknown',\n    isCNA: false,\n    isSameTab: true,\n    isMAC: true,\n  };\n\n  if (IS_LOCAL_DEV?.toString() !== 'true' && preprocessorURL) {\n    try {\n      const preHeader: Record<string, string> = {\n        Cookie: `sessionID=${context.req?.cookies?.sessionID};UserIdToken=${\n          context.req?.cookies?.UserIdToken ? context.req?.cookies?.UserIdToken : ''\n        };RememberMeUserID=${encodeURIComponent(\n          context.req?.headers?.remembermeuserid ? context.req?.headers?.remembermeuserid : ''\n        )};RememberMeAlternateID=${encodeURIComponent(\n          context.req?.headers?.remembermealternateid ? context.req?.headers?.remembermealternateid : ''\n        )};RememberMeFlag=${context.req?.headers?.remembermeflag ? context.req?.headers?.remembermeflag : ''};`,\n        'User-agent': context?.req?.headers?.['user-agent'],\n        'Accept-Language': context?.req?.headers['accept-language'] ?? 'en-US',\n        'X-Host': context?.req?.headers['x-host'] ?? '',\n      };\n      log.debug(inspect(`[PPv5-LOGS] PPv5 PREPROCESSOR URL:${preprocessorURL}`));\n      log.debug(inspect(`[PPv5-LOGS] PPv5 PREPROCESSOR Headers:${inspect(preHeader)}`));\n      preprocessorURL = `${preprocessorURL}?${query}`;\n      const preProcessorResponse = await fetch(preprocessorURL, {\n        method: 'GET',\n        headers: preHeader,\n      });\n\n      log.debug(inspect(`[PPv5-LOGS] PPv5 PREPROCESSOR RESPONSE:${inspect(preProcessorResponse)}`));\n      log.debug(inspect(`[PPv5-LOGS] PPv5 PREPROCESSOR RESPONSE:${inspect(preProcessorResponse?.data)}`));\n      if (preProcessorResponse.status === 200) {\n        response = await preProcessorResponse.json();\n        response.marsha = context?.query?.index;\n      }\n      if (!response?.validMarsha || !response?.experienceSegment) {\n        log.error(inspect(`[PPv5-LOGS] PPv5 PREPROCESSOR RESPONSE DATA:${inspect(preProcessorResponse?.data)}`));\n        error.value = true;\n        error.redirect = {\n          redirect: {\n            permanent: false,\n            destination: INVALID_REDIRECT_URL,\n          },\n        };\n        return {\n          operationSignatures: operationSignatures,\n          deployedEnvType,\n          error: error,\n          preProcessorResponse: response ?? {},\n          EXPERIENCE_SEGMENT,\n          appId: response?.appId ?? NEXT_PUBLIC_APP_NAME ?? '',\n        };\n      }\n      EXPERIENCE_SEGMENT.push(response.userSegment);\n    } catch (error: any) {\n      log.error(inspect(`[PPv5-LOGS] PPv5 PREPROCESSOR ERROR RESPONSE:${inspect(error)}`));\n      error.value = true;\n      error.redirect = {\n        redirect: {\n          permanent: false,\n          destination: INVALID_REDIRECT_URL,\n        },\n      };\n      return {\n        operationSignatures: operationSignatures,\n        deployedEnvType,\n        error: error,\n        preProcessorResponse: response ?? {},\n        EXPERIENCE_SEGMENT,\n        appId: response?.appId ?? NEXT_PUBLIC_APP_NAME ?? '',\n      };\n    }\n  } else {\n    response = sampleResponse;\n    EXPERIENCE_SEGMENT.push(response.userSegment);\n  }\n  if (state && user) {\n    response.experienceSegment = state;\n    response.userSegment = user;\n    EXPERIENCE_SEGMENT = [];\n    EXPERIENCE_SEGMENT.push(response.userSegment);\n  }\n\n  if (response.isCNA) {\n    EXPERIENCE_SEGMENT.push('CNA');\n  }\n\n  const states = ['in_stay', 'preconnect', 'connected', 'upgraded', 'upgrade'];\n  const experienceSegment = response?.experienceSegment.toLowerCase();\n  let updatedState = '';\n\n  for (let i = 0; i < states.length; i++) {\n    if (experienceSegment?.includes(states[i])) {\n      updatedState = states[i];\n      break;\n    }\n  }\n\n  response.state = updatedState;\n  response.userState = userStates.find(i => {\n    return response.experienceSegment?.toLowerCase().includes(i.toLowerCase());\n  });\n\n  response.cookie = `sessionID=${context.req?.cookies?.sessionID}`;\n  response.headersData = context.req?.headers;\n\n  return {\n    operationSignatures: operationSignatures,\n    deployedEnvType,\n    error: error,\n    preProcessorResponse: response,\n    EXPERIENCE_SEGMENT,\n    appId: response?.appId ?? NEXT_PUBLIC_APP_NAME ?? '',\n  };\n};\n\n//Make pre page calls like session, datalayer, fetch model.json, producSpecifc data etc\n//at server side and pass the data is passed as props to page component.\nexport const getServerSideProps: GetServerSideProps<any> = prePageCall(ppv5SpecificData, mockModel);\n"],"names":["NEXT_PUBLIC_AEM_PATH","getProcessEnvs","ITEM_PATH_ROOT","constants","PropertyPortalPage","model","preProcessorResponse","deployedEnvType","isAuthorMode","headersData","requestId","currentLocale","lang","MiApolloClient","useNextMiApolloClient","operationSignatures","responsiveGridModel","respGridUtil","cqItems","root","responsivegrid","metaNames","metaProperties","canonical","staticComponentClientLibsJS","staticComponentClientLibsCSS","title","context","sessionID","sessionid","locale","localePath","subDirectory","direction","rtlEnable","ApolloProvider","client","PageParamsContext","Provider","value","Layout","metaProps","gridCss","mainID","ResponsiveGrid","pagePath","itemPath"],"sourceRoot":"","ignoreList":[]}